package com.health.pay.tencent.business;

import com.health.pay.tencent.common.Log;
import com.health.pay.tencent.common.Util;
import com.health.pay.tencent.common.XMLParser;
import com.health.pay.tencent.protocol.refund.RefundReqData;
import com.health.pay.tencent.protocol.refund.RefundResData;
import com.health.pay.tencent.service.RefundService;
import org.slf4j.LoggerFactory;

public class RefundBusiness {

	public RefundBusiness() throws IllegalAccessException,
			ClassNotFoundException, InstantiationException {
		refundService = new RefundService();
	}


	// 打log用
	private static Log log = new Log(LoggerFactory
			.getLogger(RefundBusiness.class));

	// 执行结果
	private static String result = "";

	private RefundService refundService;

	public RefundResData run(RefundReqData refundReqData)
			throws Exception {

		String refundServiceResponseString;

		String objXmlString=XMLParser.map2XmlString(refundReqData.toMap());
		refundServiceResponseString = refundService.request(objXmlString);


		RefundResData refundResData = (RefundResData) Util.getObjectFromXML(
				refundServiceResponseString, RefundResData.class);
		
		return refundResData;
	}

	public void setRefundService(RefundService service) {
		refundService = service;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		RefundBusiness.result = result;
	}

	public void setResult(String result, String type) {
		setResult(result);
		log.log(type, result);
	}

}
